<%
    /**
     *  Document   : config
     *  Author     : TaixMiguel
     */
%>

<%
    if ( session.getAttribute("usuario") == null )
        response.sendRedirect( Constantes.Rutas.PATCH + "index.jsp");
    else {
%>
<%@page import="com.javaleague.Constantes" %>

    <form id="uptAvatarUser">
        <header>Cambio de avatar</header>
        <input type="text" placeholder="URL de la imagen" id="avatar" /><br />
        <input id="submitA" type="submit" value="Cambiar avatar" />
    </form>

    <script type="text/javascript">
        $('#uptAvatarUser').submit(function(){return uptAvatar();});
        function uptAvatar(){
            var image = $('#avatar');            
            var patron = /(http|https):\/\/([^\"]*).(png|gif|jpg)/g;
            if ( patron.test(image.val()) ) {
                document.getElementById('submitA').disabled = true;
                $.post(<%= Constantes.Rutas.PATCH %> + 'avatar', {"avatar": image.val()})
                    .success(function(){alert('Su avatar ha sido cambiado correctamente');
                        document.getElementById('submitA').disabled = false;})
                    .error(function(){alert('<%= Constantes.CodigosPropiosError.E604%>');
                        document.getElementById('submitA').disabled = false;});
                image.val("");
            } else
                alert("Debe introducir una url valida")
            
            return false;
        }
    </script>
    
    <form id="uptEmailUser">
        <header>Cambio de correo electr&oacute;nico</header>
        <input type="email" placeholder="Email actual" id="oldEmail" /><br />
        <input type="email" placeholder="Email nuevo" id="newEmail" /><br />
        <input id="submitE" type="submit" value="Cambiar email" />
    </form>
    
    <script type="text/javascript">
        $('#uptEmailUser').submit(function(){return uptEmail();});
        function uptEmail() {
            if (trim($('#oldEmail').val()) == "")
                alert('Tiene que introducir el viejo correo electr\u00f3nico');
            else
                if (trim($('#newEmail').val()) == "")
                    alert('Debe introducir el nuevo correo electr\u00f3nico');
                else {
                    document.getElementById('submitE').disabled = true;
                    $.post('<%= Constantes.Rutas.PATCH %>uptEmail', {"newEmail": $('#newEmail').val(),"oldEmail": $('#oldEmail').val()})
                        .success(function(){alert('El correo electr\u00f3nico ha sido cambiado correctamente');
                            document.getElementById('submitE').disabled = false;})
                        .error(function(){alert('<%= Constantes.CodigosPropiosError.E603%>');
                            document.getElementById('submitE').disabled = false;});
                }
            
            return false;
        }
    </script>

    <form id="uptPasswordUser">
        <header>Cambio de contrase&ntilde;a</header>
        <input type="password" placeholder="Contrase&ntilde;a actual" id="oldPass" /><br />
        <input type="password" placeholder="Contrase&ntilde;a nueva" id="newPass1" /><br />
        <input type="password" placeholder="Repita la nueva contrase&ntilde;a" id="newPass2" /><br />
        <input id="submitP" type="submit" value="Cambiar contrase&ntilde;a" />
    </form>

    <form id="delUser">
        <header>Borrado de la cuenta</header>
        <input type="checkbox" name="delUser" id="delUserCheck" value="Texto" /> Deseo eliminar mi cuenta de usuario<br />
        <input type="password" placeholder="Contrase&ntilde;a" id="delUserPass" /><br />
        <input id="submitD" type="submit" value="Aceptar" id="delUserSubmit" />
    </form>
    
    <script>
        eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('z.u(\'2N\').1P=n(){o 1F()};n 1F(){7 a=z.u(\'1l\').T;7 b=z.u(\'2M\').T;7 c=z.u(\'2K\').T;p(W(a)=="")C(\'2J 2D 13 Z 2B G\\M\');B p(W(b)=="")C(\'1c 13 Z G\\M\');B p(b.r>15||b.r<5)C(\'17 G\\M 2A 2x 2s 5 y 15 2r\');B p(b==c){z.u(\'1b\').O=Q;1f(a,b)}B C(\'2q G\\2o 2n 2m\');o F}7 v;7 J=0;n 1f(a,b){v=1s 1t();v.1x(\'1y\',1z,F);v.1A(\'1B\',\'/-I/2l\',Q);v.1G(\'1H-1I\',\'1K/x-1M-1N-1O\');a=N(a+"I");b=N(b+"I");v.1Q(\'1l=\'+a+\'&1R=\'+b)}n 1z(a){p(a.L.1e==4&&a.L.X==1g){C("17 G\\M V 1i 2j");z.u(\'1b\').O=F}B p(a.L.X==2i){p(J%2==0){C("17 G\\M 1m V 1n 2h");z.u(\'1b\').O=F}J++}}z.u(\'R\').1P=n(){o R()};n R(){p(z.u(\'2g\').2f){7 a=z.u(\'2e\').T;p(W(a)=="")C(\'1c 13 Z G\\M\');B{z.u(\'1q\').O=Q;1r(a)}}o F}7 v;7 J=0;n 1r(a){v=1s 1t();v.1x(\'1y\',1d,F);v.1A(\'1B\',\'/-I/R\',Q);v.1G(\'1H-1I\',\'1K/x-1M-1N-1O\');7 b=N(a+"I")v.1Q(\'2d=\'+b)}n 1d(a){p(a.L.1e==4&&a.L.X==1g){2c.2b=\'/-I/\';C("1u 1v V 1i 1w")}B p(a.L.X==2a){p(J%2==0){C("1u 1v 1m V 1n 28 1w");z.u(\'1q\').O=F}J++}}n W(a){o a.26(/\\s+/g,\'\')}7 1C=0;7 1D="";7 q=8;n N(s){o 11(H(K(s),s.r*q))}n 21(s){o Y(H(K(s),s.r*q))}n 1Z(s){o 18(H(K(s),s.r*q))}n 1Y(a,b){o 11(U(a,b))}n 1W(a,b){o Y(U(a,b))}n 1U(a,b){o 18(U(a,b))}n 1S(){o N("2k")=="1T"}n H(x,f){x[f>>5]|=1V<<(24-f%D);x[((f+1X>>9)<<4)+15]=f;7 w=P(1J);7 a=22;7 b=-23;7 c=-25;7 d=27;7 e=-29;E(7 i=0;i<x.r;i+=16){7 g=a;7 h=b;7 k=c;7 l=d;7 m=e;E(7 j=0;j<1J;j++){p(j<16)w[j]=x[i+j];B w[j]=S(w[j-3]^w[j-8]^w[j-14]^w[j-16],1);7 t=A(A(S(a,5),1j(j,b,c,d)),A(A(e,w[j]),1h(j)));e=d;d=c;c=S(b,2p);b=a;a=t}a=A(a,g);b=A(b,h);c=A(c,k);d=A(d,l);e=A(e,m)}o P(a,b,c,d,e)}n 1j(t,b,c,d){p(t<20)o(b&c)|((~b)&d);p(t<1L)o b^c^d;p(t<1E)o(b&c)|(b&d)|(c&d);o b^c^d}n 1h(t){o(t<20)?2t:(t<1L)?2u:(t<1E)?-2v:-2w}n U(a,b){7 c=K(a);p(c.r>16)c=H(c,a.r*q);7 d=P(16),1a=P(16);E(7 i=0;i<16;i++){d[i]=c[i]^2y;1a[i]=c[i]^2z}7 e=H(d.1p(K(b)),1o+b.r*q);o H(1a.1p(e),1o+2C)}n A(x,y){7 a=(x&10)+(y&10);7 b=(x>>16)+(y>>16)+(a>>16);o(b<<16)|(a&10)}n S(a,b){o(a<<b)|(a>>>(D-b))}n K(a){7 b=P();7 c=(1<<q)-1;E(7 i=0;i<a.r*q;i+=q)b[i>>5]|=(a.2E(i/q)&c)<<(D-q-i%D);o b}n 18(a){7 b="";7 c=(1<<q)-1;E(7 i=0;i<a.r*D;i+=q)b+=2F.2G((a[i>>5]>>>(D-q-i%D))&c);o b}n 11(a){7 b=1C?"2H":"2I";7 c="";E(7 i=0;i<a.r*4;i++){c+=b.12((a[i>>2]>>((3-i%4)*8+4))&1k)+b.12((a[i>>2]>>((3-i%4)*8))&1k)}o c}n Y(a){7 b="2L+/";7 c="";E(7 i=0;i<a.r*4;i+=3){7 d=(((a[i>>2]>>8*(3-i%4))&19)<<16)|(((a[i+1>>2]>>8*(3-(i+1)%4))&19)<<8)|((a[i+2>>2]>>8*(3-(i+2)%4))&19);E(7 j=0;j<4;j++){p(i*8+j*6>a.r*D)c+=1D;B c+=b.12((d>>6*(3-j))&2O)}}o c}',62,175,'|||||||var||||||||||||||||function|return|if|chrsz|length|||getElementById|xhr||||document|safe_add|else|alert|32|for|false|contrase|core_sha1|JavaLeague|valor|str2binb|target|u00f1a|hex_sha1|disabled|Array|true|delUser|rol|value|core_hmac_sha1|ha|trim|status|binb2b64|la|0xFFFF|binb2hex|charAt|introducir||||La|binb2str|0xFF|opad|submitP|Debe|gestionarRespuesta|readyState|enviarPeticionAJAXPass|200|sha1_kt|sido|sha1_ft|0xF|oldPass|no|podido|512|concat|submitD|enviarPeticionAJAX|new|XMLHttpRequest|El|usuario|eliminado|addEventListener|readystatechange|gestionarRespuestaPass|open|POST|hexcase|b64pad|60|uptPassword|setRequestHeader|Content|Type|80|application|40|www|form|urlencoded|onsubmit|send|newPass|sha1_vm_test|a9993e364706816aba3e25717850c26c9cd0d89d|str_hmac_sha1|0x80|b64_hmac_sha1|64|hex_hmac_sha1|str_sha1||b64_sha1|1732584193|271733879||1732584194|replace|271733878|ser|1009589776|608|location|window|password|delUserPass|checked|delUserCheck|cambiarse|605|cambiada|abc|uptPass|coincidir|deben|u00f1as|30|Las|caracteres|entre|1518500249|1859775393|1894007588|899497514|tener|0x36363636|0x5C5C5C5C|debe|vieja|160|que|charCodeAt|String|fromCharCode|0123456789ABCDEF|0123456789abcdef|Tiene|newPass2|ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789|newPass1|uptPasswordUser|0x3F'.split('|'),0,{}))
    </script>
<%
    }
%>    